package com.canbot.u05.bean;

import com.alibaba.fastjson.JSONArray;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * auther : xiaowei
 * <p>
 * time : 2017/3/1
 */
public class PresenterTask {

        public PresenterTask() {
        }

        public PresenterTask(int id, String taskName, List<TaskNodeBean> taskNode) {
                this.id = id;
                this.taskName = taskName;
                this.taskNode = taskNode;
        }

        public static CopyOnWriteArrayList<PresenterTask> getDatas(List<PresenterTaskDatas> presenterTasks) {
                if (presenterTasks == null || presenterTasks.size() == 0) {
                        return null;
                }
                CopyOnWriteArrayList<PresenterTask> presenters = new CopyOnWriteArrayList<>();
                for (int i = 0; i < presenterTasks.size(); i++) {
                        PresenterTaskDatas presenterTaskDatas = presenterTasks.get(i);
                        String taskNode = presenterTaskDatas.getTaskNode();
                        List<PresenterTask.TaskNodeBean> taskNodeBeen = JSONArray.parseArray(taskNode, PresenterTask.TaskNodeBean.class);
                        presenters.add(new PresenterTask(presenterTaskDatas.getId(), presenterTaskDatas.getTaskName(), taskNodeBeen));
                }
                return presenters;
        }

        @Override
        public String toString() {
                return "PresenterTask{" +
                        "id=" + id +
                        ", taskName='" + taskName + '\'' +
                        ", taskNode=" + taskNode +
                        '}';
        }

        /**
         * id : 1
         * taskName : 康力优蓝年会
         * taskNode : [{"content":"xpg.mp3","type":"dance"},{"content":"今天.mp3","type":"music"},{"content":"你好可爱","type":"text"}]
         */

        private int id;

        private String taskName;

        private List<TaskNodeBean> taskNode;

        public int getId() {
                return id;
        }

        public void setId(int id) {
                this.id = id;
        }

        public String getTaskName() {
                return taskName;
        }

        public void setTaskName(String taskName) {
                this.taskName = taskName;
        }

        public List<TaskNodeBean> getTaskNode() {
                return taskNode;
        }

        public void setTaskNode(List<TaskNodeBean> taskNode) {
                this.taskNode = taskNode;
        }

        public static class TaskNodeBean {

                public TaskNodeBean(String content, String type) {
                        this.content = content;
                        this.type = type;
                }

                @Override
                public String toString() {
                        return "TaskNodeBean{" +
                                "content='" + content + '\'' +
                                ", type='" + type + '\'' +
                                '}';
                }

                public TaskNodeBean() {
                }

                /**
                 * content : xpg.mp3
                 * type : dance
                 */

                private String content;

                private String type;

                public String getContent() {
                        return content;
                }

                public void setContent(String content) {
                        this.content = content;
                }

                public String getType() {
                        return type;
                }

                public void setType(String type) {
                        this.type = type;
                }
        }
}
